package com.tf.xx.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fasterxml.jackson.databind.util.BeanUtil;
import com.tf.xx.entity.EduCourse;
import com.tf.xx.entity.EduCourseDescription;
import com.tf.xx.entity.vo.CourseInfoForm;
import com.tf.xx.mapper.EduCourseMapper;
import com.tf.xx.service.EduCourseService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

@Service
public class EduCourseServiceImpl extends ServiceImpl<EduCourseMapper, EduCourse> implements EduCourseService{
    @Override
    public String addCourseInfo(CourseInfoForm courseInfoForm) {
        EduCourse eduCourse = new EduCourse();
        BeanUtils.copyProperties(courseInfoForm, eduCourse);
        int result = baseMapper.insert(eduCourse);

        String cid = eduCourse.getId();
        EduCourseDescription eduCourseDescription = new EduCourseDescription();
        eduCourseDescription.setDescription(courseInfoForm.getDescription());
        eduCourseDescription.setId(cid);
        return cid;
    }
}
